home *** CD-ROM | disk | FTP | other *** search
- /* This program is used to unpack the UniFLEX kermit HELP file. */
-
- #include <stdio.h>
-
- main()
- {
- char *fnm = "ufhelp.txt"; /* Default input file */
- char *outdir = "/gen/kermit"; /* Files go there */
- char *c = "~~~"; /* File name lead-in */
- FILE *ifp, *ofp;
- char data[100];
-
- ofp = -1;
- if ((ifp = fopen(fnm,"r")) == 0)
- {
- printf("Error opening input file %s\n",fnm);
- exit(1);
- }
- if (chdir(outdir))
- {
- printf("Error going to '%s'\n",outdir);
- exit(1);
- }
-
- while (fgets(data,100,ifp))
- {
- if (strncmp(c,data,3) == 0) /* lead-in string ? */
- {
- if (ofp != -1) /* Close old output file */
- fclose(ofp);
- data[strlen(data)-1] = '\0'; /* Zap trailing \n */
- if ((ofp = fopen(&data[3],"w")) == 0)
- {
- printf("Error opening output file %s\n",&data[3]);
- exit(1);
- }
- }
- else
- fputs(data,ofp); /* Copy the data */
- }
- fclose(ifp);
- fclose(ofp);
- }
-